<template>
  <div class="campus-binhai">
    <h1>温州理工滨海校区</h1>
    <div class="search-box">
      <input type="text" v-model="studentId" placeholder="请输入学号" />
      <button @click="searchStudent">搜索</button>
    </div>
    <div v-if="showStudentInfo" class="student-info">
      <h2>学生信息</h2>
      <p>学号: {{ student.id }}</p>
      <p>姓名: {{ student.name }}</p>
      <p>年龄: {{ student.age }}</p>
      <p>专业: {{ student.major }}</p>
    </div>
  </div>
</template>

<script>
export default {
  name: 'CampusBinhai',
  data() {
    return {
      studentId: '',
      showStudentInfo: false,
      student: {
        id: '',
        name: '',
        age: 0,
        major: ''
      },
      // 模拟学生数据
      students: [
        { id: '123456', name: '李小明', age: 18, major: '计算机科学' },
        { id: '234567', name: '张三', age: 20, major: '电子工程' },
        { id: '345678', name: '王五', age: 19, major: '机械工程' }
      ]
    }
  },
  methods: {
    searchStudent() {
      const foundStudent = this.students.find(student => student.id === this.studentId)
      if (foundStudent) {
        this.student = foundStudent
        this.showStudentInfo = true
      } else {
        alert('未找到该学生信息')
        this.showStudentInfo = false
      }
    }
  }
}
</script>

<style>

</style>
